import { AxiosResponse } from 'axios';
import { Get, Post } from '../axios';



/* 删除开发者账号*/
interface DelcerInterface {
    (data: {
        id: string,                     /*开发者账号id*/
    }): Promise<AxiosResponse<any>>
}
export const delcer: DelcerInterface = async (data) => {
    try {
        return await Post({ url: "/cerapi/delcer", data });
    } catch (error) {
        throw error
    }
}



/* 修改开发者账号 */
interface UpcerInterface {
    (data: {
        id: string,                    /* 开发者账号id */
        status: boolean,               /* 开发者账号状态 */
    }): Promise<AxiosResponse<any>>
}
export const upcer: UpcerInterface = async (data) => {
    try {
        return await Post({ url: "/cerapi/upcer", data });
    } catch (error) {
        throw error
    }
}



/* 查询开发者账号 */
interface GetcerInterface {
    (data: {
        pageNo: number,                    /* 当前页数 */
        pageSize: number,                  /* 页面总条数 */
        id?: string | null
    }): Promise<AxiosResponse<any>>
}
export const getcer: GetcerInterface = async (data) => {
    try {
        return await Post({ url: "/cerapi/getcer", data });
    } catch (error) {
        throw error
    }
}



/* 搜索开发者账号 */
interface SchcerInterface {
    (data: {
        name: string                     /*备注*/
    }): Promise<AxiosResponse<any>>
}
export const searchcer: SchcerInterface = async (data) => {
    try {
        return await Get({ url: "/cerapi/searchcer", data });
    } catch (error) {
        throw error
    }
}



/* 初始化开发者账号 */
interface InitcerInterface {
    (data: {
        id: string,                     /*开发者账号id*/
    }): Promise<AxiosResponse<any>>
}
export const initcer: InitcerInterface = async (data) => {
    try {
        return await Post({ url: "/cerapi/initcer", data });
    } catch (error) {
        throw error
    }
}



/* 开发者账号校验 */
interface ValicerInterface {
    (data: {
        id: string,                     /*开发者账号id*/
    }): Promise<AxiosResponse<any>>
}
export const valicer: ValicerInterface = async (data) => {
    try {
        return await Post({ url: "/cerapi/valicer", data });
    } catch (error) {
        throw error
    }
}


/* 上传p8文件 */
export const addP8cer = async (data: FormData): Promise<AxiosResponse<any>> => {
    try {
        return await Post({ url: "/cerapi/addp8cer", data });
    } catch (error) {
        throw error
    }
}



/* 账号登录 */
interface AddapiKeysInterface {
    (data: {
        name: string,
        pass: string,
        type: string,
        data?: {}
    }): Promise<AxiosResponse<any>>
}
export const addapiKeys: AddapiKeysInterface = async (data) => {
    try {
        return await Post({ url: "/cerapi/apiKeys", data });
    } catch (error) {
        throw error
    }
}



